Skip to main content

Relational Model

Domains in the Relational Model

In relational database theory, a domain is the set of all possible valid values that an attribute (column) can take.

  • Every attribute in a relation (table) is associated with exactly one domain.
  • A domain ensures consistency, integrity, and correctness of data.
  • For example, if we have an attribute Age, its domain should be all non-negative integers (0,1,2, …).

Key Characteristics of Domains:

  1. Atomic values only – Each value in a domain must be indivisible (no multiple values in one attribute). Example: A PhoneNumber domain should store one phone number, not multiple in a single cell.

  2. Defined set of constraints – Domains can restrict valid values (like range, format, etc.). Example: The domain for Percentage could be all decimal numbers between 0 and 100.

  3. Uniformity across tables – If the same domain is reused across different attributes, it guarantees consistency. Example: CustomerEmail and EmployeeEmail might both use a VARCHAR(100) domain with email format constraints.

Data Types in Relational Databases

Domains are implemented in practice using data types in a DBMS (e.g., MySQL, PostgreSQL, Oracle, SQL Server).

Common Data Types:

  1. Numeric Data Types
  • INT, BIGINT → Integer values.
  • DECIMAL(p, q) / NUMERIC(p, q) → Fixed-point decimal numbers (good for money).
  • FLOAT, REAL, DOUBLE → Approximate floating-point numbers.

Example:

Salary DECIMAL(10,2) → allows values like 45000.50, with 10 digits in total and 2 after the decimal.

  1. Character / String Data Types
  • CHAR(n) → Fixed-length string (e.g., CHAR(10) always uses 10 spaces).
  • VARCHAR(n) → Variable-length string (efficient for text).
  • TEXT / CLOB → Large text storage.

Example:

Name VARCHAR(50) → can store up to 50 characters.

  1. Date and Time Data Types
  • DATE → Stores year, month, day.
  • TIME → Stores hour, minute, second.
  • DATETIME / TIMESTAMP → Stores both date and time (with time zone support in some DBMS).

Example:

HireDate DATE → stores values like 2025-08-27.

  1. Boolean Data Types
  • BOOLEAN or BIT → True/False values.

Example:

IsActive BOOLEAN → can be TRUE or FALSE.

  1. Special / Other Data Types (DBMS-specific)
  • BLOB (Binary Large Object) → images, videos, files.
  • ENUM → predefined list of values.
  • UUID → unique identifiers.

Example:

Gender ENUM('Male','Female','Other') → restricts entries to only these three.